<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="title">
            <h:outputText value="Master Production Schedules (Weekly)"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:form prependId="false">
                <p:panel header="Master Production Schedules (Weekly)">
                <h:panelGroup rendered="#{masterProductionScheduleWeeklyEntityController.items.rowCount > 0}">
                    <p:dataTable value="#{masterProductionScheduleWeeklyEntityController.items}" 
                                     var="item" style="table-layout:fixed"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">
                        
                        <p:column style="width:16px">  
                                <p:rowToggler />  
                        </p:column>
                        
                        <p:column filterBy="#{item.weekOfProduction}">
                            <f:facet name="header">
                                <h:outputText value="Week"/>
                            </f:facet>
                            <h:outputText value="#{item.weekOfProduction}"/>
                        </p:column>
                        <p:column filterBy="#{item.monthOfProduction}">
                            <f:facet name="header">
                                <h:outputText value="Month"/>
                            </f:facet>
                            <h:outputText value="#{item.monthOfProduction}"/>
                        </p:column>
                        <p:column filterBy="#{item.yearOfProduction}">
                            <f:facet name="header">
                                <h:outputText value="Year"/>
                            </f:facet>
                            <h:outputText value="#{item.yearOfProduction}"/>
                        </p:column>
                        <p:column filterBy="#{item.productionType}">
                            <f:facet name="header">
                                <h:outputText value="Production Line"/>
                            </f:facet>
                            <h:outputText value="#{item.productionType}"/>
                        </p:column>
                        <p:column>
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <p:commandButton image="ui-icon ui-icon-search" action="#{masterProductionScheduleWeeklyEntityController.prepareView}" ajax="false"/>
                        </p:column>
                        
                        <p:rowExpansion>  
                                <p:dataTable value="#{masterProductionScheduleWeeklyEntityController.weeklyMPS(item)}" 
                                             var="week" style="table-layout:fixed">

                                    <p:columnGroup type="header">  
                                        <p:row rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==false}"> 
                                            <p:column rowspan="2" headerText="Week" />
                                            <p:column rowspan="2" headerText="Working Days in Week"/>
                                            <p:column colspan="2" headerText="Classic Nutri Bar" /> 
                                            <p:column colspan="2" headerText="Premium Power Bar" />
                                        </p:row>  
                                        <p:row rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==true}"> 
                                            <p:column rowspan="2" headerText="Week" />
                                            <p:column rowspan="2" colspan="2" headerText="Working Days in Week"/>
                                            <p:column colspan="4" headerText="Classic Nutri Bar" /> 
                                            <p:column colspan="4" headerText="Premium Power Bar" />
                                        </p:row> 

                                        <p:row rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==false}">  
                                            <p:column headerText="Nuts" />  
                                            <p:column headerText="Fruits" />  
                                            <p:column headerText="Chocolate Nuts" />  
                                            <p:column headerText="Redcurrant Fruits" />  
                                        </p:row> 
                                        <p:row rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==true}"> 
                                            <p:column colspan="2" headerText="Nuts" />  
                                            <p:column colspan="2" headerText="Fruits" />  
                                            <p:column colspan="2" headerText="Chocolate Nuts" />  
                                            <p:column colspan="2" headerText="Redcurrant Fruits" />  
                                        </p:row>
                                    </p:columnGroup>

                                    <p:column>
                                        <h:outputText value="#{week.weekOfProduction}"/>
                                    </p:column>
                                    <p:column>
                                        <h:outputText value="#{week.weeklyWorkingDays1}"/>
                                    </p:column>
                                    <p:column rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==true}">
                                        <h:outputText value="#{week.weeklyWorkingDays2}"/>
                                    </p:column>
                                    <p:column>
                                        <h:outputText value="#{week.classicNuts}"/>
                                    </p:column>
                                    <p:column rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==true}">
                                        <h:outputText value="#{week.classicNuts2}"/>
                                    </p:column>
                                    <p:column>
                                        <h:outputText value="#{week.classicFruits}"/>
                                    </p:column>
                                    <p:column rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==true}">
                                        <h:outputText value="#{week.classicFruits2}"/>
                                    </p:column>
                                    <p:column>
                                        <h:outputText value="#{week.premiumNuts}"/>
                                    </p:column>
                                    <p:column rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==true}">
                                        <h:outputText value="#{week.premiumNuts2}"/>
                                    </p:column>
                                    <p:column>
                                        <h:outputText value="#{week.premiumFruits}"/>
                                    </p:column>
                                    <p:column rendered="#{masterProductionScheduleWeeklyEntityController.checkForWeek5(masterProductionScheduleWeeklyEntityController.weeklyMPS(item))==true}">
                                        <h:outputText value="#{week.premiumFruits2}"/>
                                    </p:column>

                                </p:dataTable>
                            </p:rowExpansion>
                    </p:dataTable>
                </h:panelGroup>
                </p:panel>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
